/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-11-18 17:37:43
 * @LastEditors: Andy
 * @LastEditTime: 2023-01-30 10:03:32
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/components/layout/layoutView.vue'
import { parentRoutes, subRoutes } from '../config/autoRouters'

Vue.use(VueRouter)
const routers = [
  {
    path: '/',
    component: Layout,
    hidden: true,
    redirect: '/home',
    children: [...subRoutes]
  },
  ...parentRoutes
]
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch((err) => err)
}
const router = new VueRouter({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({
    y: 0
  }),
  routes: routers
})

export default router
